#include<iostream>
using namespace std;

#ifndef __RATIONAL__

#define __RATIONAL__

class Rational {
	mutable long num;
	mutable unsigned long den;
	
	void canonize() const;
	
	void swap(Rational &);
	
public:
	
	Rational() : num(0), den(1) { }
	
	Rational(long);
	
	Rational(long, unsigned long);
	
	Rational(Rational const &);
	
	Rational & operator += (Rational const &);
	
	Rational & operator -= (Rational const &);
	
	Rational & operator *= (Rational const &);
	
	Rational & operator /= (Rational const &);
	
	Rational & operator ++ ();
	
	Rational const & operator ++ (int);
	
	Rational & operator -- ();
	
	Rational const & operator -- (int);
	
	explicit operator double () const;
	
	~Rational() {};

	friend bool operator == (Rational const &, Rational const &);
	
	friend bool operator <= (Rational const &, Rational const &);
	
	friend bool operator >= (Rational const &, Rational const &);
	
	friend bool operator < (Rational const &, Rational const &);
	
	friend bool operator > (Rational const &, Rational const &);
	
	friend bool operator != (Rational const &, Rational const &);
		
	friend ostream & operator << (ostream &, Rational const &);

};

Rational operator + (Rational const &, Rational const &);
	
Rational operator - (Rational const &, Rational const &);

Rational operator * (Rational const &, Rational const &);
	
Rational operator / (Rational const &, Rational const &);
	
Rational operator - (Rational const &);


#endif